package com.xxxx.server.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxxx.server.mapper.SvaccineMapper;
import com.xxxx.server.pojo.Admin;
import com.xxxx.server.pojo.RespPageBean;
import com.xxxx.server.pojo.Svaccine;
import com.xxxx.server.pojo.Tvaccine;
import com.xxxx.server.mapper.TvaccineMapper;
import com.xxxx.server.service.ITvaccineService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 教职工疫苗登记表 服务实现类
 * </p>
 *
 * @author zhoubin
 * @since 2022-06-04
 */
@Service
public class TvaccineServiceImpl extends ServiceImpl<TvaccineMapper, Tvaccine> implements ITvaccineService {


    @Autowired
    private TvaccineMapper tvaccineMapper;
    @Override
    public List<Tvaccine> getByColegeIdTvaccine() {
        return tvaccineMapper.getByColegeIdTvaccine(((Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getCollegeid());
    }

    @Override
    public RespPageBean getTvaccineByPage(Integer currentPage, Integer size, Tvaccine tvaccine, String[] beginDateScope, int type, String collegeName, int collegeid) {
        //开启分页
        Page<Tvaccine> page = new Page<>(currentPage,size);
        IPage<Tvaccine> tvaccineByPage = tvaccineMapper.getTnvaccineByPage(page, tvaccine, beginDateScope,type,collegeName,collegeid);
        RespPageBean respPageBean = new RespPageBean(tvaccineByPage.getTotal(), tvaccineByPage.getRecords());
        return respPageBean;
    }

    @Override
    public List<Tvaccine> getTnvaccineSeachList(Tvaccine tvaccine, String[] beginDateScope, int type, String collegename, int collegeid) {
        return tvaccineMapper.getTnvaccineSeachList(tvaccine, beginDateScope,type,collegename,collegeid);
    }

}
